<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>影厅维护</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body onload="init();">
<script type="text/javascript">
    function check() {
        if ($("#hallName").val() == "") {
            alert("请输入影厅名称");
            $('#hallName').focus();
            return false;
        }
        if ($("#row").val() == "") {
            alert("请输入总排数");
            $('#row').focus();
            return false;
        }
        if (isNaN($("#row").val())) {
            alert("总排数只能输入数字字符");
            $('#row').focus();
            return false;
        }
        if ($("#col").val() == "") {
            alert("请输入座位数/排");
            $('#col').focus();
            return false;
        }
        if (isNaN($("#col").val())) {
            alert("座位数只能输入数字字符");
            $('#col').focus();
            return false;
        }
        if ($("#id").val() == "") {
            $("#id").val(0);
        }
        return true;
    }

    function init() {
        var key = $("#id").val();

    }

    function back() {
        location.href = "${pageContext.request.contextPath }/movieHall/list";
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }
</script>
<table class="tablelist2">
    <tbody>
    <tr>
        <td class="tableselect2" style="border-bottom:none;">
            <div class="tools">
                <ul class="toolbar">
                    <li class="click"><a href="javascript:void(0);" onclick="back();"><i></i>返回</a></li>
                </ul>
            </div>
        </td>
    </tr>
    </tbody>
</table>
<form action="${pageContext.request.contextPath }/movieHall/save" id="movieHallform" method="post"
      onsubmit="return check();">
    <input type="hidden" name="hallId" id="id" value="${movieHall.hallId}"></input>
    <table cellpadding="0" cellspacing="0" width="1000" style="margin: 0 auto">
        <tr height="30">
            <td align="right" width="90">影厅名称</td>
            <td><input type="text" name="hallName" id="hallName" value="${movieHall.hallName}" style="width:200px"/>
            </td>
        </tr>
        <tr height="30">
            <td align="right">影厅类别</td>
            <td>
                <select name="hallTypeId" id="hallTypeId" style="width:200px">
                    <c:forEach items="${hallTypeList}" var="v">
                        <c:if test="${movieHall.hallTypeId==v.hallTypeId}">
                            <option value="${v.hallTypeId}" selected>${v.hallTypeName}</option>
                        </c:if>
                        <c:if test="${movieHall.hallTypeId != v.hallTypeId}">
                            <option value="${v.hallTypeId}">${v.hallTypeName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <tr height="30">
            <td align="right">所属机构</td>
            <td>
                <select name="agentId" id="agentId" style="width:200px">
                    <c:forEach items="${agentList}" var="v">
                        <c:if test="${movieHall.agentId==v.agentId}">
                            <option value="${v.agentId}" selected>${v.agentName}</option>
                        </c:if>
                        <c:if test="${movieHall.agentId != v.agentId}">
                            <option value="${v.agentId}">${v.agentName}</option>
                        </c:if>
                    </c:forEach>
                </select>
                <input type="text" name="agentName" id="agentName" cssStyle="width:200px"
                       onkeyup="changeAgent2(this.value);"></input>
            </td>
        </tr>
        <tr height="30">
            <td align="right">总排数</td>
            <td><input type="text" name="row" id="row" style="width:200px" value="${movieHall.row}"/></td>
        </tr>
        <tr height="30">
            <td align="right">座位/排</td>
            <td><input type="text" name="col" id="col" style="width:200px" value="${movieHall.col}"/></td>
        </tr>
        <tr height="30">
            <td align="right">状态</td>
            <td>
                <select name="state" id="state" style="width:200px">
                    <option value="0" <c:if test="${movieHall.state==0}">selected</c:if>>禁用</option>
                    <option value="1" <c:if test="${movieHall.state==1}">selected</c:if>>启用</option>
                </select>
            </td>
        </tr>
        <tr height="30">
            <td align="right">备注说明</td>
            <td><input type="text" name="remark" id="remark" value="${movieHall.remark}" style="width:200px"/></td>
        </tr>
        <tr style="background-image: url('images/maintitle.jpg')">
            <td></td>
            <td><input type="submit" value="  保 存  " name="isEmpty"></td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    var orgjson = {"data": []};

    function initAgentJson() {
        $("#agentId option").each(function () {
            var item = {"value": this.value, "text": this.text};
            orgjson.data.push(item);
        });
    }

    initAgentJson();

    function changeAgent2(value) {
        $("#agentId").empty();
        $.each(orgjson.data, function (i, item) {
            if (item["text"].indexOf(value) >= 0) {
                $("#agentId").append("<option value='" + item["value"] + "'>" + item["text"] + "</option>");
            }
        });
    }
</script>
</body>
</html>